extends MySprites

@onready var animation_player: AnimatedSprite2D = $Animation

func _init():
	# 在初始化时修改变量的默认值
	max_health = 200
	health = 200
	attack = 30
	defence = 20
	is_player = false
	current_position = 2
	physical_position = 2

func _ready() -> void:
	animation_player.play("Idle")

#哥布林的大招:恢复自己20%生命值
func use_ultimate_ability(players: Array, _enemies: Array) -> void:
	var self_player = players[physical_position]
	var heal_value = int(attack * 0.1)
	await play_ultimate_animation(animation_player)
	heal_self(self_player, heal_value)
	play_idle_animation(animation_player)
	switch_turn(is_player)
		
#哥布林的普通技能:恢复自己10%生命值
func use_basic_ability(players: Array, _enemies: Array) -> void:
	var self_player = players[physical_position]
	var heal_value = int(attack * 0.1)
	await play_basic_animation(animation_player)
	heal_self(self_player, heal_value)
	play_idle_animation(animation_player)
	switch_turn(is_player)

	
func my_sprite_killed() -> void:
	animation_player.play("Death")
	await animation_player.animation_finished
	visible = false
